package club.cearnach.security.provider.impl;

import club.cearnach.security.provider.AuthorizeConfigProvider;
import club.cearnach.security.provider.MovieAuthorizeConfigProviderManager;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer;
import org.springframework.stereotype.Component;

import java.util.Set;

/**
 * @author 阮胜
 * @date 2018/5/23 14:22
 */
@Component
public class MovieAuthorizeConfigProviderManagerImpl implements MovieAuthorizeConfigProviderManager {
    private final Set<AuthorizeConfigProvider> authorizeConfigProviderSet;

    public MovieAuthorizeConfigProviderManagerImpl(Set<AuthorizeConfigProvider> authorizeConfigProviderSet) {
        this.authorizeConfigProviderSet = authorizeConfigProviderSet;
    }

    @Override
    public void configure(ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrlRegistry config) {
        for (AuthorizeConfigProvider authorizeConfigProvider : authorizeConfigProviderSet) {
            authorizeConfigProvider.configure(config);
        }
    }
}
